<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        while (true) {
            // 计算类型
            var calcType = prompt('请输入计算类型\n加\n减\n乘\n除\n退');

            if (calcType === '退') {
                break;
            }

            // 错误判断
            if (!(calcType === '加' || calcType === '减' || calcType === '乘' || calcType === '除')) {
                alert('输入有误 请重新输入');
                continue;
            }

            var n1 = prompt('输入第一个数');
            var n2 = prompt('输入第二个数');
            var result;

            switch (calcType) {
                case '加':
                    result = `${n1} + ${n2} = ${Number(n1) + Number(n2)}`;
                    break;
                case '减':
                    result = `${n1} - ${n2} = ${n1 - n2}`;
                    break;
                case '乘':
                    result = `${n1} * ${n2} = ${n1 * n2}`;
                    break;
                case '除':
                    result = `${n1} / ${n2} = ${n1 / n2}`;
                    break;

                default:
                    break;
            }

            alert(result);
        }

    </script>
</body>
</html>